define(["jquery","fastclick"], function(jquery,FastClick) {
  FastClick.attach(document.body);

});

//iOS用于js交互必备代码：
function setupWebViewJavascriptBridge(callback) {
    if (window.WebViewJavascriptBridge) { return callback(WebViewJavascriptBridge); }
    if (window.WVJBCallbacks) { return window.WVJBCallbacks.push(callback); }
    window.WVJBCallbacks = [callback];
    var WVJBIframe = document.createElement('iframe');
    WVJBIframe.style.display = 'none';
    WVJBIframe.src = 'wvjbscheme://__BRIDGE_LOADED__';
    document.documentElement.appendChild(WVJBIframe);
    setTimeout(function() { document.documentElement.removeChild(WVJBIframe) }, 0)
}



//判断是否是安卓还是ios
function isAndroid_ios(){
    var u = navigator.userAgent, app = navigator.appVersion;
    var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; //android终端或者uc浏览器
    var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
    return isAndroid==true?true:false;
}

if(isAndroid_ios()){ //当前设备是安卓
   var token = AndroidForJs.checkLogin("拿本地token");
   alert("杨呆萌传的token是:"+token);
    if (token != null && token != '') {
        $.ajaxSetup({
            dataType: "json",
            cache: false,
            headers: {
                "token": token
            },
            xhrFields: {
                withCredentials: true
            }
        });
    }
}else{ //当前设备是ios
    //native调用js
    setupWebViewJavascriptBridge(function(bridge) {
        bridge.registerHandler('testJSFunction', function(data, responseCallback) {
            alert('JS方法被调用:'+data);
            responseCallback('js执行过了');
        });
        bridge.callHandler('checkLogin', "{\"content\" : \"王大江666\"}", function(response) {
            alert('native被调用:' + response);
            if (response != null && response != '') {
                $.ajaxSetup({
                    dataType: "json",
                    cache: false,
                    headers: {
                        "token": response
                    },
                    xhrFields: {
                        withCredentials: true
                    }
                });
            }
            // document.getElementById("returnValue").value = response;
        });
    })

}

// //登录token
// var token = sessionStorage.getItem("token");
// alert("token="+token);
// // localStorage.clear();
//
// if(token != 'null' && token != null){
//   // parent.location.href = baseURL + 'login.html';
//   //jquery全局配置
//   //   alert('token是:'+token);
//     $.ajaxSetup({
//         dataType: "json",
//         cache: false,
//         headers: {
//             "token": token
//         },
//         xhrFields: {
//             withCredentials: true
//         }
//     });
// }




